<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="/html/js/getParameter.js"></script>
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/axios.js"></script>
<script type="text/javascript" src="../../js/api.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<link href="../../layui/css/layui.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>采购单管理</li>
    <li>采购单详情</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>采购单信息</span></div>
  <ul class="forminfo">
    <li>
      <label>采单编号</label>
      <cite id="purchaseId"></cite><!--CG201711180001-->
    </li>
    <li>
      <label>采购时间</label>
      <cite id="purchaseTime"></cite><!--2017-11-18 15:36:10-->
    </li>
    <li>
      <label>总金额</label>
       <cite id="money"></cite><!--￥9,876,582-->
    </li>
    <li>
      <label>操作人</label>
      <cite id="creatorName"></cite><!--关羽-->
    </li>
    <li>
      <label>审核状态</label>
      <cite id="checkStatus"></cite><!--已审核通过-->
    </li>
    <li>
      <label>审核意见</label>
      <cite id="checkOpinion"></cite><!--做的很详细，同意通过-->
    </li>
    <li>
      <label>审核人</label>
      <cite id="auditName"></cite><!--曹操-->
    </li>
    <li>
      <label>审核时间</label>
      <cite id="auditTime"></cite><!--2017-01-30 12:05:05-->
    </li>
    <li>
      <label>入货仓库</label>
      <cite id="rhck"><a href="../storage/storageView.html?ID=" title="点击查看客户详细信息" class="tablelink" id="cName"></a></cite>
    </li>
    <li>
      <label>入库时间</label>
      <cite id="rkDate"></cite><!--2013-09-09 15:05:05-->
    </li>
    <li>
      <label>入库人</label>
      <cite id="uName"></cite><!--朱元璋-->
    </li>
    <li>
      <label>入库状态</label>
      <cite id="state"></cite><!--已入库-->
    </li>
  </ul>
  <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>品牌</th>
          <th>类型</th>
          <th>型号</th>
          <th>厂商</th>
          <th>数量</th>
          <th>单位</th>
          <th>单价</th>
          <th>金额</th>
        </tr>
      </thead>
      <tbody id="detaillist">
       <!-- <tr>
          <td>1</td>
          <td>联想</td>
          <td>笔记本电脑</td>
          <td>T470</td>
          <td>北京联想科技股份有限公司</td>	
          <td>10</td>
          <td>台</td>
          <td>9998</td>
          <td>99980</td>
        </tr>
        <tr>
          <td>2</td>
          <td>联想</td>
          <td>笔记本电脑</td>
          <td>X260</td>
          <td>北京联想科技股份有限公司</td>	
          <td>5</td>
          <td>台</td>
          <td>5500</td>
          <td>27500</td>
        </tr>-->
      </tbody>
  </table>
  <div style="margin-top:20px; margin-left:20px;">
  <input name="" type="button" class="btn" value="返回" onclick="window.history.go(-1);"/>
  </div>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
    $(function () {
      loadRkWarehouseDetail()
      queryware()
    })

    let parameter = getParameter("purchaseId");

    //加载数据
    function loadRkWarehouseDetail() {

      axiosJson('get', '/purchase/detail', null, {purchaseId: parameter}).then((res) => {
        writeRkWarehouseDetail(res, purchaseId)
      })
    }

    //写数据
    function writeRkWarehouseDetail(res, purchaseId) {
      let pur = res.data.resultData;
      console.log(pur)
      $("#purchaseId").html(parameter)                      //采购单编号
      $("#purchaseTime").html(pur.purchase.purchaseTime)    //采购时间
      $("#money").html('￥' + pur.purchase.totalMoney)      //采购总金额
      $("#creatorName").html(pur.purchase.creator.uName)    //操作人

      let auditStatus1 = auditStatus(pur.purchase.checkStatus);
      $('#checkStatus').html(auditStatus1)      //审核状态

      $('#checkOpinion').html(pur.purchase.checkOpinion)    // 审核意见
      $("#auditName").html(pur.purchase.checkUser.uName)    //审核人
      $("#auditTime").html(pur.purchase.checkTime)          //审核时间
      // $('#cName').html(pur.rkWarehouse.warehouse.cname)     //入货仓库
      // $('#rkDate').html(pur.rkWarehouse.rkDate)             //入库时间
      // $('#uName').html(pur.rkWarehouse.user.uName)          //入库人
      //
      //  let state1 = rkState(pur.rkWarehouse.state);
      // $('#state').html(state1)                       //入库状态

      let pro = pur.purchaseData;
      console.log(pro)
      let str = ''
      for (let i = 0; i < pro.length; i++) {
        str += '<tr>\n' +
                '                <td>' + (i + 1) + '</td>\n' +
                '                <td>' + pro[i].brandName + '</td>\n' +
                '                <td>' + pro[i].typeName + '</td>\n' +
                '                <td>' + pro[i].productModel + '</td>\n' +
                '                <td>' + pro[i].firmName + '</td>\n' +
                '                <td>' + pro[i].count + '</td>\n' +
                '                <td>' + pro[i].productUnit + '</td>\n' +
                '                <td>' + pro[i].purchasePrice + '</td>\n' +
                '                <td>' + pro[i].totalMoney + '</td>\n' +
                '            </tr>'
      }
      $('#detaillist').html(str)
      $('.tablelist tbody tr:odd').addClass('odd');
    }

    //判断审核状态
    function auditStatus(num) {
      let status=num
      if (num==1){
        status= '未审核'
      }
      if (num==2){
          status='审核中'
      }
      if (num==3){
        status='审核通过'
      }
      if (num==4){
        status='审核未通过'
      }
      return status;
    }
    //判断入库状态
    function rkState(num) {
      console.log(num)
      let state = num
      console.log(state)
      if (state ==1){
        state= '未入库'
      }
      if (state== 2){
        state= '已入库'
      }
      return state;
    }
    function queryware() {
      var id = getParameter("id");
      var ID = 'id='+id//{id:id}
      console.log(ID)
      axiosRequest("post", "/warehouse/rkPageBean", ID)
              .then((res) => {
                var ware = res.data.data[0];
                var city = "<a href=\"../storage/storageView.html?ID="+getParameter("id")+"\" title=\"点击查看客户详细信息\" class=\"tablelink\" id=\"cName\">"+ware.warehouse.cName+"</a>"
                $('#rhck').html(city)
                $('#rkDate').html(ware.rkDate)
                $('#uName').html(ware.user.uName)
                var s = ""
                if (ware.state==1){
                  s = "未入库"
                }else if (ware.state==2){
                  s = "已入库"
                }
                $('#state').html(s)
              })
    }
</script>
</body>
</html>
